version: "3.9"

x-def-logging: &default-logging
  logging:
    driver: "loki"
    options:
      loki-url: "http://localhost:3100/loki/api/v1/push"
      loki-batch-size: "100"
      loki-retries: 2
      loki-max-backoff: 1000ms
      loki-timeout: 1s

services:
  nginx:
    image: nginx
    hostname: nginx-entrypoint
    container_name: nginx-entrypoint
    restart: unless-stopped
    <<: *default-logging
    environment:
      TZ: "Europe/Moscow"
    ports:
      - 80:80
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost" ]
      interval: 10s
      timeout: 10s
      retries: 20

  loki:
    hostname: loki
    image: grafana/loki:2.9.0
    environment:
      TZ: ${SYSTEM_TIMEZONE:-Europe/Moscow}
    volumes:
      - ./loki/retention-config.yaml:/etc/loki/retention-config.yaml
    ports:
      - "3100:3100"
    command: -config.file=/etc/loki/retention-config.yaml

  grafana:
    hostname: grafana
    environment:
      - GF_PATHS_PROVISIONING=/etc/grafana/provisioning
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
      - TZ=${SYSTEM_TIMEZONE:-Europe/Moscow}
    volumes:
      - ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources
    image: grafana/grafana:latest
    ports:
      - "3000:3000"